package com.zyh.scs.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyh.scs.admin.api.dto.UserPaymentDTO;
import com.zyh.scs.admin.api.vo.PaymentExcelVO;
import com.zyh.scs.admin.service.UserPaymentService;
import com.zyh.scs.common.core.util.R;
import com.zyh.scs.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hwh
 * @ClassName: 支付管理访问层$
 * @Description: $
 * @Date $
 * @Version 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/payment")
@Tag(description = "payment", name = "支付管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class UserPaymentController {

    private final UserPaymentService userPaymentService;

    /**
     * 分页查询支付列表
     *
     * @param page 参数集
     * @return 用户集合
     */
    @GetMapping("/page")
    @Operation(summary = "分页查询支付列表", description = "分页查询支付列表")
    @PreAuthorize("@pms.hasPermission('scsx_payment_view')")
    public R getPaymentPage(@ParameterObject Page page, UserPaymentDTO userPaymentDTO) {
        return R.ok(userPaymentService.getPaymentPage(page, userPaymentDTO));
    }

    /**
     * 导出Excel 支付列表
     *
     * @param userPaymentDTO
     */
    @GetMapping("/getPaymentExcel")
    @ResponseExcel
    @Operation(summary = "导出Excel 支付列表", description = "导出Excel 支付列表")
    public List<PaymentExcelVO> getPaymentExcel(UserPaymentDTO userPaymentDTO) {
        return userPaymentService.getPaymentExcel(userPaymentDTO);
    }
}
